
/**
 * Created by wxnacy on 2015/8/12.
 */
$(function() {
    initPlayVideo();
});

/**
 * 初始化播放视频的按钮
 */
function initPlayVideo(){
    //视频列表中的点击元素
    var $openVideo = $('button[data-target=".play-video"]');

    $openVideo.each(function(){
        playVideo($(this));
    });

}

function playVideo($openVideo){
    $openVideo.click(function(){
        console.log($openVideo);
        var videoId = $(this).attr('video-id');
        $.get(URL_VIDEO_LETV+videoId,function(data,status){
            if(status == 'success'){
                var success = data.success;
                if(success){
                    //var video_unique = data.data.video_unique;
                    var url = data.data;
                    console.log(url);
                    //var src = 'http://yuntv.letv.com/bcloud.html?uu=53f80d6851&vu='+video_unique+'&auto_play=1&gpcflag=1&width=760&height=380';
                    $('#video-iframe').attr('src',url);

                }else{
                    var msg = data.msg;// '直播类型暂不支持播放';
                    var type = 'error';
                    var $layout = 'topRight';
                    notyRestart(msg,type,$layout);
                }
            }
        });
    });
}